local m = require('utils.vim')
local e = require('utils.editor')

-- 避免影响默认剪贴板
m.map("n", "d", '"_d',{desc="used together with f/t, delete until and without change current clipboard"})
m.map("n", "D", '"_D',{desc="delete line content after cursor"})
m.map("n", "C", '"_C',{desc="change line content after cursor"})
m.map("n", "c", '"_c',{desc="used together with f/t, change until and without change current clipboard"})
m.map("v", "d", '"_d',{desc="delete selected text"})

-- abs
m.map("n", "<leader>i", '<cmd>iabbrev<cr>',{desc="show all abbreviations"})

-- 缩进
m.map("n", "<", '<<',{desc="indent line to the left"})
m.map("n", ">", '>>',{desc="indent line to the right"})

--see: visual-surround
m.map("v", "<", '<gv',{desc="indent selected text to the left"})
m.map("v", ">", '>gv',{desc="indent selected text to the right"})

-- current date
m.map("n", ",cd", function()
    local dt = os.date("%Y-%m-%d")
    e.copy(os.date("%Y-%m-%d"))
    require('notify')(dt .. ' copied')
end,{desc="copy current date"})

-- redo (same with <C-r>)
m.map("n", "<space>r", '<cmd>redo<cr>',{desc="redo last change"})

-- add ; into end of line
-- Thanks: https://www.reddit.com/r/neovim/comments/1d45jiz/awesome_remap_adding_semicolon_at_eol_my_everyday/
m.map("n", ",;", function()
    local cursor = vim.api.nvim_win_get_cursor(0)
    vim.cmd('norm A;') -- norm is a shortcut for normal, `A` is the command in normal mode
    vim.api.nvim_win_set_cursor(0, cursor)
end,{desc="add ; into end of line"})

-- insert blank line
m.map('n', ',o', 'o<Esc>k', { noremap = true, silent = true, desc="insert blank line below" })
m.map('n', ',O', 'O<Esc>j', { noremap = true, silent = true, desc="insert blank line above" })

-- Disable abbreviation expansion when blink.cmp is on
m.map('i', '<Space>', '<Space>')

-- misc
m.map("n", "0", "^",{desc="go to the first char of current line"})

-- EOP
